import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { UserServiceModule } from './user-service.module';
import { ServiceRegistry } from '@app/common';
async function bootstrap() {
  const app = await NestFactory.create(UserServiceModule);
  const serviceRegistry = app.get(ServiceRegistry);
  // 启动微服务
  const microservice = app.connectMicroservice<MicroserviceOptions>({
    transport: Transport.TCP,
    options: {
      host: '0.0.0.0',
      port: 3001,
    },
  });

  await app.startAllMicroservices();

  // 注册服务
  await serviceRegistry.register('user-service', 3001);
  await app.listen(process.env.port ?? 3000);
}
bootstrap();
